package com.yatang.yiliao.app.activities;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.view.Window;
import com.yatang.yiliao.app.Constants;
import com.yatang.yiliao.app.R;


public class SplashActivity extends FragmentActivity implements Runnable {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_splash);
        Thread thread=new Thread(this);
        thread.start();
    }

    @Override
    public void run() {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e)
        {
            e.printStackTrace();
        }
        show();
    }
    private  void show()
    {
        SharedPreferences sp=getSharedPreferences(Constants.APP_DATA,MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putBoolean(Constants.APP_IS_ACCEPT_PROTOCOL,true);
        edit.commit();
        boolean showSplash=sp.getBoolean(Constants.APP_SHOW,false);
        if(showSplash==true)
        {
            startActivity(new Intent(this,LoginActivity.class));
        }
        else
        {
            startActivity(new Intent(this,TutorialActivity.class));
        }
        finish();
    }
}
